const App = {
    data() {
        return {
            form: {},
            oldform:null,
            loading: false,
        };
    },
    mounted() {
        let ls_URL = window.location.href;
        let nodeKey = getQueryObject(ls_URL, "nodeKey");// 获取 nodeKey 参数
        this.getData(nodeKey);
    },
    methods: {
        getData(nodeKey) {
            $.ajax({
                headers: {
                    "content-type": "application/x-www-form-urlencoded",
                    "Session": 'session5'
                },
                url: `${y}/generalQueryByTableName`,
                type: "POST",
                data:{
                    TableName:"base_word_log",
                    Condition:`Work_Log_SerialNumber = '${nodeKey}'`,
                    Original:"1"
                },
                success: (res) => {
                    if (res.Status == 'success'&&res.Data.length == '1') {
                        this.form = res.Data[0];
                    }
                },
                dataType: "json",
            });
        },
        goBack() {
            window.history.go(-1);
        },
        handleSubmit() {
            this.loading = true;
            let obj = {
                Modify:{
                    base_word_log:[this.form]
                }
            }
            $.ajax({
                headers: {
                    "content-type": "application/x-www-form-urlencoded",
                    "Session": 'session5'
                },
                url: `${y}/generalSave`,
                type: 'POST',
                data: {
                    Data: JSON.stringify(obj)
                },
                success: (res) => {
                    if (res.Status === 'success') {
                        this.$message.success("提交成功");
                        window.location.href = './index.html'
                    } else {
                        this.$message.error("提交失败，请稍后再试");
                    }
                },
                complete: (XMLHttpRequest) => {
                    this.loading = false
                },
                dataType: "json"
            })
        }
    },
};
const { createApp, ref } = Vue;
const app = createApp(App);
app.use(ElementPlus, { locale: zhCn });
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
app.component('yl-upload', ylUpload);
app.component('yl-text-editor', ylTextEditor);
const ElMessage = ElementPlus.ElMessage;
app.mount("#app");
